package com.jack.payment.service.basic;

import com.jack.payment.constant.ResultHintConstant;
import com.jack.payment.dao.billing.BillingDao;
import com.jack.payment.entity.common.BusinessException;
import com.jack.payment.entity.filter.PayFilter;
import com.jack.payment.entity.generate.billing.BillingModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BillingServiceImpl {
    private Logger log = LoggerFactory.getLogger(BillingServiceImpl.class);

    @Autowired
    private BillingDao billingDao;

    /**
     * 筛选出流水账单有多少条
     * @param billingFilter
     * @return
     */
    public Integer filterBillingCount(PayFilter.BillingFilter billingFilter) throws BusinessException {
         return billingDao.filterBillingCount(billingFilter);
    }

    /**
     * 筛选出详细的流水信息
     * @param billingFilter
     * @return
     */
    public List<BillingModel> filterBillingList(PayFilter.BillingFilter billingFilter) throws BusinessException{
        List<BillingModel> resultBillingList = billingDao.filterBillingRecordList(billingFilter);
        if (resultBillingList.isEmpty()) {
            log.warn("筛选流水数据为空");
            throw new BusinessException(ResultHintConstant.DATA_NOT_EXIST);
        }
        return resultBillingList;
    }
}
